package com.mzj.saas.mservice.roles.repository;

import com.mzj.saas.mservice.roles.entity.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface RoleRepository
        extends PagingAndSortingRepository<Role, Long>, JpaSpecificationExecutor<Role>, JpaRepository<Role, Long> {
    List<Role> findAllByOrgIdAndPropertyOrderByPropertyTypeDesc(Long orgId, Integer property);

    List<Role> findAllByOrgIdAndPropertyAndPropertyType(Long orgId, Integer property, Integer propertyType);

    Role findByIdAndProperty(Long Id, Integer property);

    List<Role> findByParentId(Long parentId);

    Role findByNameAndOrgId(String name, Long orgId);

    Role findByNameAndPropertyAndOrgId(String name, Integer property, Long orgId);

    Role findByOrgIdAndType(Long orgId, Integer type);

    Role findByOrgIdAndPropertyAndName(Long orgId, Integer property, String name);

    Role findAllByOrgIdAndPropertyAndNameOrderByPropertyTypeDesc(Long orgId, Integer property, String name);

    Role findByIdAndOrgIdAndPropertyAndType(Long id, Long orgId, Integer property, Integer type);

    List<Role> findByOrgId(Long orgId);

    Role findByCodeAndOrgId(String code, Long orgId);
}
